<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>
<form action="" name="ct" >
    <div>
        <select onchange="document.form.ct.submit();" id="manage_country" name="manage_country" style="float: left">
            <option disabled="disabled" selected>-- Select Region --</option>
            <option value="1">Asia</option>
            <option value="2">America</option>
            <option value="3">Australia</option>
            <option value="4">Europe</option>
            <option value="5">Africa</option>
        </select>
        <input type="submit" value='<?php _e('Display Country',$text_domain);?>' class='like-a-button' />
    </div>
</form>

<?php
   print '<table clas="add_location_form">';
    print '<tr><div>';
    print '<label>Region ID</label>
           <select name="sl_region_id" id="sl_region_id">
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
           </select><br/>
           <label>Country Name</label>
           <input name="sl_country_id"><br/>
           <label>Region Name</label>
           <input name="sl_region"><br/>';
    print '</div></tr>';
    print '</table>';

    print '<table class="slplus widefat" cellspacing="0">';
    print '<thead>';
    print '<tr>
                <th colspan="1">
                    <input class="button" type="checkbox" onlclick="checkAll(this,document.forms["locationForm"])">
                </th>
                <th colspan="1">Actions</th>
                <th>Country ID</th>
                <th>Region ID</th>
                <th>Country Name</th>
                <th>Region Name</th>
           </tr>';
    $countries = $wpdb->get_results('SELECT * FROM '.$wpdb->prefix.'country',ARRAY_A);
    if(isset($_GET['edit'])){
        $show_country = 'display:none;';
        $show_edit = '';
    }
    else{
        $show_country = '';
        $show_edit = 'display:none;';
    }
    foreach ($countries as $country){
        $locID = $country['sl_country_id'];
        print '<tr style="background-color:#FA8072; '.$show_country.'">
                  <td><input type="checkbox" id="check_'.$country["sl_country_id"].'"></td>
                  <td class="thnowrap">
                        <a class="action_icon edit_icon" title="Edit" href="'.ereg_replace("&edit=".(isset ($_GET['edit'])?$_GET['edit']:''),"",$_SERVER['URI'])."
                            &edit=".$locID."#a".$locID."".'></a>
                        <a class="action_icon delete_icon" title="Delete"></a>
                  </td>
                  <td>'.$country["sl_country_id"].'</td>
                  <td>'.$country["sl_region_id"].'</td>
                  <td>'.$country["sl_country"].'</td>
                  <td>'.$country["sl_region"].'</td>
               </tr>';
        
        print '<tr style="'.$show_edit.'">
                    <table class="widefat" cellpadding="0">
                        <tbody>
                            <tr style="border-top-right-radius: 3px;border-style: solid;background-color: #F1F1F1;     
                                background-image: -moz-linear-gradient(center top , #F9F9F9, #ECECEC);">
                                <th>Enter An Country</th>
                            </tr>
                            <tr>
                                <td>
                                    <table>
                                        <tbody>
                                            <tr>
                                                <td>
                                                    <div class="add_location_form">
                                                        <label for="store-15">Region ID</label>
                                                        <select name="sl_region_id">
                                                            <option value="1">1</option>
                                                            <option value="2">2</option>
                                                            <option value="3">3</option>
                                                            <option value="4">4</option>
                                                        </select><br>
                                                        <label>Country Name</label>
                                                        <input name="sl_country"></input><br>
                                                        <label>Region Name</label>
                                                        <input name="sl_region"></input><br>
                                                    </div>
                                                </td>
                                            </tr>
                                        </tbody>
                                        <tfoot>
                                            <td><nobr><input type="button" onclick="postMyForm();"  value="'.__("Update", SLPLUS_PREFIX).'" class="button-primary">
                                                      <input type="button" class="button" value="'.__("Cancel", SLPLUS_PREFIX).'" onclick="location.href=\"'.ereg_replace("&edit=".$_GET['edit']."", "",$_SERVER['REQUEST_URI']).'>
                                            </nobr></td>
                                        </tfoot>
                                     </table>
                                     <br>
                                </td>
                            </tr>
                        </tbody>
                    </table>
               </tr>';
    }
    print '</thead>';
    print '</table>';

    
?>